babl: set babl_rel_avg_error to a high value on NaN
authorØyvind Kolås <pippin@gimp.org>
Mon, 25 Sep 2017 20:46:21 +0000 (22:46 +0200)
committerØyvind Kolås <pippin@gimp.org>
Mon, 25 Sep 2017 20:46:24 +0000 (22:46 +0200)
In relation to bug #787441, if the sum of errors contain a nan the sum
is nan, we return pi as a much higher than expected average error to
indicate that this is not 0.0.

babl/babl-util.c

index 9b08913676de1094349cf873edf40baddf4687c2..23c1513f9760eaf76113944a46609cffe35d50de 100644 (file)
@@ -91,10 +91,12 @@ babl_rel_avg_error (const double *imgA,
   for (i = 0; i < samples; i++)
     error += fabs (imgA[i] - imgB[i]);
 
-  if (error >= 0.000001)
+  if (error >= 0.0000001)
     error /= samples;
-  else
+  else if (error <= 0.0)
     error = 0.0;
+  else
+    error = M_PI;
 
   return error;
 }